//
// Created by xili on 2024/9/10 16:29.
// GO BIG OR GO HOME.
//
#include "leetcode.h"

class Solution {
public:
    int minIncrementForUnique(vector<int> &nums) {
        ranges::sort(nums);
        int n = nums.size();
        int ans = 0;
        for (int i = 1; i < n; i++) {
            if (nums[i] <= nums[i - 1]) {
                int diff = nums[i - 1] + 1 - nums[i];
                nums[i] += diff;
                ans += diff;
            }
        }
        return ans;
    }
};